#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
int dp[40000];
int num[40000];
int main() {
	int t;
	scanf("%d", &t);
	while (t--) {
		int p;
		scanf("%d", &p);
		for (int i = 1; i <= p; i++) {
			scanf("%d", &num[i]);
			dp[i] = 1;
		}
		for (int i = 1; i <= p; i++) {
			for (int j = 1; j < i; j++) {
				if (num[j] < num[i]) {
					dp[i] = max(dp[i], dp[j] + 1);
				}
			}
		}
		int ans = 0;
		for (int i = 1; i <= p; i++) {
			//cout << "dp " << dp[i] << endl;
			ans = max(ans, dp[i]);
		}
		//cout << "ans " << ans << endl;
		cout << ans << endl;
	}
	//system("pause");
}
